package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class DNR extends AbstractData {
	private long id = -1;
	private long hotelId;
	private Date date;
	private Date dateTo;
	private long roomId;
	private String description;
	
	public DNR(){}
	
	public DNR(long id)
	{
		this.id = id;
	}
		
	public void setId(long id) {
		this.id = id;
	}

	public long getId() {
		return id;
	}
	public long getHotelId() {
		return hotelId;
	}

	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	public Date getDateTo() {
		return dateTo;
	}
	
	public void setDateTo(Date dateTo) {
		this.dateTo = dateTo;
	}

	public long getRoomId() {
		return roomId;
	}

	public void setRoomId(long roomId) {
		this.roomId = roomId;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Override
	public Entity getEntity()
	{
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.DNR);
		else
			item = new Entity(this.key);
		
		item.setProperty("hotelId", this.hotelId);
		item.setProperty("date", this.date);
		item.setProperty("dateTo", this.dateTo);
		item.setProperty("roomId", this.roomId);
		item.setProperty("description", this.description);
		
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("hotelId");
		this.date = (Date) entity.getProperty("date");
		this.dateTo= (Date) entity.getProperty("dateTo");
		this.roomId= (Long) entity.getProperty("roomId");
		this.description= (String) entity.getProperty("description");

		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.DNR, this.id);
			setEntity(entity);
		}
	}
}
